<?php

namespace Home\Controller;

use Think\Controller;

class UserCommonController extends Controller
{
    public function _initialize()
    {
        $user = D('User');
        if (!$user->is_login()) {
            header("Location:" . __ROOT__ . '/');
        }
        $uid      = session('ytata.uid');
        $userinfo = $user->get_user_one($uid, true);
        $lv       = D('Lv')->get_lv_one($userinfo['exp_lv']);

        $userinfo['percentage'] = $user->get_exp_percentage($userinfo['exp'], $lv['exp_max']);
        $this->assign('user', $userinfo);
        $this->assign('lv', $lv);
        $this->assign('page_as', 'user');
    }
}